package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	FloatTest()
}

//浮点类型的存储分为三个部分：符号位+指数位+尾数位  在存储过程中  精度会有丢失
func FloatTest() {
	var price float32 = 89.12
	fmt.Println(price)
	var num1 float32 = -0.012323
	var num2 float64 = -34545.5454
	fmt.Println(num1, num2)
	//科学计数法
	num3:=5.1234E2
	fmt.Println(num3)

	num4:=5.124E-2
	fmt.Println(num4)

}
func StringTest() {
	str := "hello你好"
	fmt.Println(len(str))

	for i, value := range str {
		fmt.Printf("索引为:%d,具体得值为:%c \n", i, value)
	}

	r := []rune(str)
	for i := 0; i < len(r); i++ {
		fmt.Printf("%c", r[i])
	}
	fmt.Println()
	//字符串转整数
	num1, _ := strconv.Atoi("555")
	fmt.Println(num1)
	//整数转字符串
	str1 := strconv.Itoa(88)
	fmt.Println(str1)

	count := strings.Count("golangjava", "an")
	fmt.Println(count)

	fold := strings.EqualFold("go", "Go")
	fmt.Println(fold)

	split := strings.Split("helllo-2323", "-")
	fmt.Println(split)

	upper := strings.ToUpper("Go")
	fmt.Println(upper)
	//字符串左右空格
	space := strings.TrimSpace("  asg sd  ")
	fmt.Println(space)
	trim := strings.Trim("aaaa-", "-")
	fmt.Println(trim)
	prefix := strings.HasPrefix("htttp://sds.fmt", "jps")
	fmt.Println(prefix)
}
